import { getCookies } from "@/utils/cookies"
import { get } from "@/utils/http"
Page({
  data: {
    isSel:'0',
    loading: false,
    info:[],
    isLogin: null
  },
  onLoadOrder(state: string) {
    this.setData({ isSel: state })
    this.initData(state)
  },
  selTag(el){
    let tag = el.target.dataset.tag
    if (this.data.isSel === tag) return
    this.setData({
      isSel:tag
    })
    this.initData(this.data.isSel)
  },
  initData(state: string = '0') {
    get('/order/queryById',{
      user_id: getCookies('id'),
      order_state: state,
    }).then(res => {
      this.setData({
        info: res.result
      })
    }).catch(err => {
      console.log('订单信息加载失败');
    })
  },
  goDetail(event) {
    wx.navigateTo({
      url: "/layout/indent/detail/index?obj=" + JSON.stringify(event.target.dataset.item)
    })
  },
  goLogin() {
    wx.navigateTo({
      url: "/layout/user/login/index"
    })
  },
  onShow() {
    this.initData()
    this.setData({ isLogin: getCookies('code') })
  }
})